Part Number Hot Search : 
74HCT109 5KE200A BNBSP 2SD2114K FDUE1245 MUR160 TDA9109 PT100
Product Description
Full Text Search
 

To Download AN2352 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  application n o te AN2352 i2c-usb bridge usage author : valeriy kyrynyuk asso ciated project : yes asso ciated part family : cy8c248 94 soft w a re version : psoc de sign er? v . 4.3 asso ciated applica t ion notes and kits : an23 04, cy324 0-i2 usb, cy3242-i o x >> availa ble in cypress onlin e store abstract t h is applicati o n note, w h ich is inclu d e d in the cy32 40-i 2 u sb kit ava i l abl e in the c y press onli ne store, detai ls severa l examp l es usin g the i2c-usb brid ge d e sig n . it is a l so a s u ppl ement t o th e i2c-usb bridge quick st art guide reference [2] at the end of this docum ent, als o avail a b l e in cy32 40-i2us b. t h e appl ica t ion note co ntains d e tails a b out implem enti ng an i 2 c interface i n to e x isti ng pr ojects and usi ng i 2 c communic a tio n to test, debug and tun e dev ic e desi gns. introducti on t he normal capa bil i ties of a pc can be w e ll e x pa nde d upo n b y usi ng the ne w i2c- u sb bridg e an d its supporti ng soft w a r e . a p c w i th i2c- u sb bri dge ca n be usef ul for follo w i ng tasks: ? deb ug e x isti ng projects (usi ng i 2 c communic a tion instea d of uar t , for exampl e) . ? acquir e an d mani pul ate data from various i 2 c devic es, such as adcs, dac s , io exp and er s, sensors w i t h i 2 c interfaces, et c. ? program eep rom, sram devices. ? t r ain users an d demo n strate i 2 c devic e cap abil i ties. t h is applicati o n note d e tai l s the follo w i n g exampl es of brid ge usa ge: 1. monitori ng c a p s ense cs r us er modu le o per ation. 2. monitori ng tac hometer o per ation. 3. w o rking w i th a 20- pi n io port e x p a nder w i th eeprom. 4. programming 24cxxx ser i al eeprom devices. 5. w o rking w i t h a psoc-bas ed 3 - chan nel p o ten t iometer. t he simplest w a y to im plem ent i 2 c into a psoc proj ect and attach the dev ice to the brid ge w i l l a l so be lo oke d at closel y. t h is docum ent do e s not descri b e the inter nal structure a n d protoco l of the bri dge. f o r th is i n formatio n refer to the i2c-usb bridge guide refere nce [1] at the end of this doc um ent, also avai l abl e in c y 32 4 0 -i2usb. t h e usb2iic.exe p r ogram w a s us ed in al l e x amp l es. details o f this progr am ar e descri bed i n [2]. attach device t o br idge exec ute the fo llo w i n g steps to conn ect the devic e to the i2c-usb bridge: 1. con nect gnd of the devic e to gnd of the bridge. 2. con nect the sda, scl lines to the bridg e (f igure 1). bridg e has 2.2 k pull- up resist ors conn ected to + 5 v. 3. po w e r th e dev i c e from the vd d pin on th e br idg e if it does not h a ve its o w n po w e r supp l y . note that the conn ectio n of vdd bet w e en the bridg e a nd targe t boar d is re quired, eve n if th e b oar d is s e lf- po w e red. t he bridg e can (o ption a ll y) pr ovi de 3.3v o r 5v, or it can w o rk w i th a n ext e rna l l y po wered b oar d usin g 2.4v to 5 . 6v. 4. con nect the bri dge to usb. 5. run usb2iic.exe program from pc. 6. select the bri d ge i n the l i st at the bottom c e nter of the screen. 9/22/2006 revision ** - 1 -
AN2352 7. click th e lis t button in the usb2iic.exe program. t he list of a ll c onn ected i 2 c d e vices w i l l app ear. not e that if the bri d g e is pr ovid i ng po w e r, it is nec essar y t o turn the po w e r on befor e the lis t button w i ll w o rk. no w d e sig ners can w o rk w i th all liste d dev ice s . figure 1. i2c-usb bridge implement i 2 c inter f ace i n to psoc a tool that can contin uous l y collect an d di spla y vari ab le valu es is v e r y useful d u rin g de bu ggi ng/t e sting psoc- base d pro j ects . readi ng me a s ureme n t resul t s, pin states and d y n a mic modific a tion of devic e pr op erties are tasks commonl y p e r f ormed b y d e sig ners. t h e uart user module is frequently used for such tasks. but such a method co ntai ns severa l disa dvanta ges: ? t he design r e q u ires o ne s par e dig i tal ps oc block for half-d upl e x u a rt operatio n. (t he i 2 c i n te rfa c e hard w a r e is i n d epe nd ent of the dig i tal bl ocks .) ? some com pute r s, particul a rl y noteb ooks, d o not hav e com ports a nd c o mmun i c a tion ca pab iliti e s for a uart . a usb-uart bridge is need ed. ? t he add ition a l lev e l-br idg e , such as a m ax232, is necess a r y on the des ig ned b oard. ? t he band w i dth of an i 2 c-us b brid ge is gr e a ter tha n the ban d w i d th of a standard uart . t he maxim u m ban d w i d th for a uart is about 11 kb/s, but i2c-usb brid ge can attain a 25kb/s b a n d w i d th. t a king into acc ount ev er y t hin g menti one d a bove, us ing an i2c-usb br id g e is m o re s u it abl e a nd c h e a per th an other solutions. t o implement the i 2 c slave i n terface into a psoc pro j ect, the follo w i n g steps are re qu ire d : ? place the ezi2 cs user mod u l e in the pso c proj ect. ? set the follo w i ng user module parameters: o slave _ ad dr to 1 (this addr e ss can be almost an yth i n g , it is not restricted to 1) o address _ t y pe to static o rom_register s, in most cases, to disab le o i 2 c clock to 400 khz fast o i 2 c pins to p1[ 0 ]-p1 [1] or p1[5]-p1[7] ? defin e the ra m buffer that w ill cont ain d a ta requ ired for i 2 c transmi ssion. defi ne the arra y or stru cture w h os e ad dress w i ll be s pecifi e d w h e n the setram buffer function is ca ll ed . f o r exampl e: struct i2c_regs { // example i2c interface structure word wx1; // read/write value int iadc; // read only value byte bstatus; // read only value } myi2c_regs; ? insert, into the initia liz at ion p a rt of program, the follo w i n g t w o st rings: ezi2cs_setrambuffer(ci2cread,ci2cwrite,(byte *)&myi2c_regs); ezi2cs_start(); ? set the argum ents of e z i2cs _setra mb uffer function to proper va lu e s . length of da ta, w h ich cou l d be read, is set by ci2cread argum ent and le ngth of data, w h ich c oul d be w r itten, is set b y ci2cwrite . t he addr ess of the i 2 c buffer is set b y myi2c_regs, wh i c h is the third arg u ment. once the ab ov e steps are c o mplete, ther e i s no ad ditio n a l code req u ire d to sup port i 2 c communic a tio n . t he ezi2cs user mod u l e w o rks in th e b a ckgro und w i t h i 2 c interru pt han dlers. t he first by te receiv ed b y i 2 c slave is th e offset into the buffer from w here d a ta w i ll be rea d from or w r itten to. defau l t offset is 0. t here is on e as pect t hat sh oul d be consi dere d w h en w o rkin g w i t h the i 2 c buffer. if the size of the var i ab le go ing into the buf fer is gr eater than 1 b y t e , a speci a l tech ni q ue must b e us ed. f i rst, al w a ys d i sa ble th e interru pt befor e chan gi ng or readi ng this varia b le i n the progr am. sec ond, v e rif y th e p e rmissib ilit y of vari abl e access. t o implem ent this, t he pr ogram m u st ana l y ze th e ezi2cs bram _rw c ntr varia b le. t h is varia b le p o i n ts to current tra n smi ssion in de x of the i 2 c b u ffer. w i thout suc h ana l y sis, the si tuation d e p i ct e d in f i gur e 2 can occur. 9/22/2006 revision ** - 2 -
AN2352 f i g u r e 2. examp l e o f erro neo u s t r an smissio n o f w o r d -t y p e va riab le 00 ff 255 w o rd ty pe v a r i able into i 2 c buffer cur r ent buffer i ndex of i 2 c int e r r upt ser v i c e i 2 c sends 00 h t h is is msb by te of w o rd val u e 01 00 256 w o rd ty pe v a r i able into i 2 c buffer cur r ent buffer i ndex of i 2 c int e r r upt ser v i c e step 1. i 2 c sends m s b by te of w o rd valu e step 2. program upda tes i 2 c buffer w o rd v a lue chan ged by 1 01 00 256 w o rd ty pe v a r i able into i 2 c buffer cu r r ent buffer index of i 2 c inter r upt se rvi c e step 3. i 2 c s e nds ls b by te of word valu e i 2 c sends 00 h t h is is ls b by te of w o rd val u e 9/22/2006 revision ** - 3 -
AN2352 belo w is the si mple e x am pl e of i 2 c slave im plem entatio n in a psoc pr oj ect: cod e 1. i 2 c sl ave implem ent ation extern byte ezi2cs_bram_rwcntr; struct i2c_regs { // example i2c interface structure word wx1; //read/write value int iadc; // read only value byte bstatus; // read only value } myi2c_regs; void main() { word wlop; int ia; ezi2cs_setrambuffer(5, 2, (byte *) &myi2c_regs); // set up ram buffer m8c_enablegint; // turn on interrupts ezi2cs_start(); // turn on i2c ............ // wx1 access m8c_disablegint; //!!! turn off interrupt if variable holds more than 1 byte! if (ezi2cs_bram_rwcntr!=1)wlop=myi2c_regs.wx1; m8c_enablegint; // turn on interrupt ........... ............ // iadc access m8c_disablegint; //!!! turn off interrupt if variable holds more than 1 byte! if (ezi2cs_bram_rwcntr!=3) myi2c_regs.iadc=ia; m8c_enablegint; // turn on interrupt ........... ........... // bstatus access is not need interrupt disable myi2c_regs.bstatus=0x20; ........... } ex am ples of bridge usa g e d u ring te sting a nd de bugging proj ects as w a s d e scri bed earl i er, th e i2c-usb bri dge is an id eal appr oach t o a pc-bas ed d a t a acqu isitio n s y stem. t he collect ed d a ta can b e use d to cali brate, rate accur a c y , optimiz e devi c e param eter s and pre p a re rep o rts. hard w a re co nfi gurati on of suc h a s y stem i n cl udes a n i2c- usb brid ge, a pc w i t h w i nd o w s ? 20 00\ xp i n stall ed, an d a commu nica tion pr ogr am (in this d e sig n it w a s usb2iic.exe ). let?s cons ider ho w a pc-ba s ed data ac qu isition s y ste m can be used to test an d d ebu g pro j ects b y e x am ini n g three examp l es. t he first e x am p l e is a tach o m eter pro j ect (test2_t ach project). t h is proj ect measu r es the inp u t freque nc y (r an ge 20- 200 00 hz) and se nd s this value to the pc via the brid ge. t he inp u t frequenc y e n ters throug h port pi n p 0 [7] and t he i 2 c i n terface uses p 1 [5] an d p1[7]. t he slave_a d d r par ameter is 0. t he comma nd l i ne for the usb2iic.exe p r ogram, w h ich reads tach ome t er values, is as follo w s : s 01 xk3 xk2 xk1 xk0 p f i gure 3 sho w s a di agr am of d a ta c o l l e c ted from t h e tachometer. 9/22/2006 revision ** - 4 -
AN2352 f i g u r e 3. t ach o m eter me asu rem e n t s t he second e x am pl e pr oject (test3_ca p ) d e monstrates a caps ense- driv en ke yp ad. it indic a tes a n d collects dat a from the csr user mod u le measurem ent s. t h is data hel ps mo nitor ke ypa d perfor m ance a nd opt imize the csr user mod u le p r operti es an d pcb la yo ut. t he slav e_a ddr param eter for t h is e x ampl e is set to 5. f i gur e 4 sho w s the oper ation of this proj ect ? the perio d valu e duri n g sequ enti a l pres sing of ke yp ad buttons. t he command line of this exa m ple is as fol l o w s : s 0b xk1 xk0 xl1 xl0 xm1 xm0 xn1 xn0 p f i g u r e 4. csr ke y p ad perio d samp les k g f e d c b l g f e d c b m g f e d c b n g f e d c b 40 0 35 0 30 0 250 200 150 10 0 50 0 6 00 0 5 50 0 5 00 0 4 50 0 4 00 0 3 50 0 3 00 0 2 50 0 2 00 0 9/22/2006 revision ** - 5 -
AN2352 t he third exa m ple pr oject ( t est4_adc3) demo n strates a lo w - cost, thre e chan nel, l o w - f r equ enc y osc ill oscop e bas ed on the cy8c 2 7 x43 devic e a nd us es a pc . t h is proj ect can be mo difie d to a larger n u mber of cha n nels (u p to 8) and great er a dc reso luti on (up to 1 2 b i ts). t he current proj ect uses a t r iadc8, w h i c h can attai n p e rformanc e of up to 600 0 sa mples p e r sec ond for eac h chan nel. t he burst mode of the brid ge tr ansmits this d a ta to the pc. in burst mode, the bri d g e transmits u p to 25 kb/s, w h ic h is eno ugh ba nd w i dth for this proj ect. f u rthermore, thi s proj ect allo w s desi gners to c han ge the pga gain val ue. t he pga gai n ca n b e d y n a mical l y adj us ted for better sensitivit y, w h i c h all o w s me a s ureme n t of a w i der r a n ge of sign als. t he first three b y t e s i n the i 2 c buffers are the pga gai n val ues, w h ich hav e t he pga_s e t_gain functi on format. f o llo w i n g is th e comma nd li n e that sets up a ga in v a l ue fo r each an al og in put: first in put gai n is set to 2 (0 x7 8 va lue), secon d in put g a in is s e t to 1 (0xf 8) and th ir d inp u t gai n is set to 0.5 (0x 7 0). s 02 00 78 f8 70 p t o read adc samples, the offset addres s for the adc data into th e i 2 c buffer should be set first at: s 02 03 p t he follo w i ng comman d strin g w i l l re ad s a mples from th e devic e in hi gh- spee d burst mode: s 03 xk0 xl0 xm0 p t he samples w e re rec o rde d at about 1 0 seconds. a dia g ram of the receiv ed dat a i s sho w n b e l o w (f igure 5). figure 5 . thre e cha nne l a d c sa mple s 9/22/2006 revision ** - 6 -
AN2352 io expander usage w i th bridge a goo d e x am ple of i2c-us b brid ge im pl ementati on is usag e of the c y pr ess io port e x p and er, cy8 c 95 20 . comman d li ne exampl es us i ng usb2iic.exe , for w o rking w i t h the 20- pi n io expa nd er, are descri bed b e lo w . t he cy8c95 2 0 e x p a n der h a s 20 pi ns, w h ich can be separ atel y c o n f igure d to s e v e ral m o d e s. t he c o mman d string be lo w sh o w s ho w pins on io exp and e r port 0 can be config ured ( ta ble 1 ). register 0x18 selects w h ich expa nd er port i s to be config u r ed. s 42 18 00 s 42 19 9f 00 cd 71 04 02 10 80 01 48 20 ta ble 1 . pin confi gura t ion o f ex pa nde r port 1 regist er value descrip tion 19 9f interrup t mask register 1a 00 pwm output r e gister 1 b c d i n v e r s i o n r e g i s t e r 1 c 7 1 input/out p u t reg i s t e r 1d 04 pull up drive mode pins 1e 02 pull dow n drive mode pins 1f 10 open d r ain high drive mode pins 20 80 open d r ain lo w drive mode pins 21 01 strong d r ive mode pins 22 48 strong slo w d r ive mode pins 23 20 high z drive mo de pins t he state of exp a n der i n p u ts can b e re ad f r om regist ers w i t h 0..2 address: s 42 00 s 43 x x x p t he pins? outp u t data are c o ntro ll ed b y re gi sters that hav e 0x08..0 x0a ad dress. t he follo w i n g e x ampl e turns to zero all o u tputs of p o rt 0 and turn s to 1 all out puts of port 1: s 42 08 00 ff p t he interrupt status regist ers can be read to detect expa nd er in pu t activit y . t h is feature is v e r y us eful for counti ng qua nti t y of certa i n ph ysic al v a lu es s u ch as w a ter, gas or electric it y . t he interr upt status reg i sters start a t register 0 x 1 0 . belo w is a co mmand stri ng that rea d s th e interru pt status from all three expa nd er ports : s 42 10 s 43 x x x p rememb er th at the interr up t status reg i ster is up date d each tim e a n activit y on th e in put p i n is prese n t an d interrupt mask bit of the pin is set to 0 (register 0x19). t he cy8c9520 expand er also has sever a l pwm blocks, w h ich outp u t can be direct ed to the o u tput pins. t h e freque nc y ra n ge for th e p w ms is from 12 m h z to 0.000 00 01 hz. t h e y can b e u s ed for transforming a di gital sign al to a pu l s e-dur ation a n a lo g si gn al, or even as a l o w - spee d dac w i t h hi gh-res i s t ance o u tput. t he examp l e bel o w sh o w s the initi a liz ation strin g s, w h ich tur n the pw m1 to a fre que nc y of 3.5 hz w i t h 50% d u t y c y cle. t he output of the pw m is sent to pin 2 4 of the e x p a n der (port1[3]): s 42 18 01 s 42 1a 08 p //set pwm pin s 42 21 01 s 42 1a 08 p //set pin mode s 42 28 00 s 42 29 04 68 34 p //set pwm1 parameters moreov er, the cy8c9520 ex p ander has built -in eeprom, w h ich is av ail abl e for use w i t h i 2 c m a ster. t o ena bl e eeprom, use the follo w i ng string: s 42 2d 43 4d 53 02 p once this com m and stri ng e x ecutes, eepr om is avail a b l e at address 0 x 8 0 + e xp an der a ddress, or 0 x a 2 , in this case. let?s w r ite 8 b y tes to eeprom address of 0 x 0 0 2 0 : s a2 00 20 00 11 22 33 44 55 66 77 p no w , w e w i ll re ad 4 b y tes fro m address 0 x 0 024: sa2 00 24 s a3 x x x x p 9/22/2006 revision ** - 7 -
AN2352 t h e e x pa nd er a l l o w s desi g ne rs to sa ve cu rre n t config uratio n s e ttings to ee prom. in future us e, thes e config uratio n s e ttings can be automatica l l y load ed u pon start up. use the comm and string b e lo w t o save curre nt config uratio n s e ttings as d e fa ult: s 42 30 01 p f o r more detai l s on port e x p a nder o per ation, refer to [3]. progr am ming i 2 c eeprom usi ng bridge t he cy8c9 5 2 0 e x p a n der c a n be us ed to w r it e a nd r e a d data from sta n dard i 2 c eep rom or sra m devic es. t he progr am bintousb2iic.exe , w h ich w a s add ed to th is appl icatio n not e , conv erts b i n a r y d a ta to a c o mman d fil e . t o program the devic e, th e g e n e rated comman d fil e shou ld b e op ene d in usb2iic.exe pro g r am and a l l comman d strin g s e x ecut ed. t he follo w i ng steps must be performe d to program a n i 2 c memor y dev ice: 1 . d e te rmi ne the i 2 c a ddr ess of the devic e to b e progr ammed. t o do this, cli ck the scan bu tto n an d choos e the a ppro p riate a d d ress from the list of ide n tified devic es. 2. pass the bi nar y fil e (dat a for programm i ng) throug h the bintousb2iic.exe pro g ram. t h ree parameter s must be e n te red int o the comman d li ne of the progr am: file n a me of i n p u t and outp u t file s (defau lt output file is data.txt ) and de vice i 2 c addre ss (default is 0xa 0 ). f o r exam pl e: bintousb2iic.exe data.bin data.txt a2 3. open the o u tput file in the usb2iic.exe program. send a ll com m and strin g s b y ch eckin g the ?send all strings? bo x a n d clickin g the se nd button. after this, the device w i ll b e pr ogramm ed. concl u si on t h is applicati o n note dem on strates ho w t o effectivel y p a ir an i2c-usb bridg e w i t h the usb2iic.exe soft w a r e progr am. if interested, r ead throu gh th e doc umentati on o n the brid ge i n te rnal pr otocol a nd structure [1 ]. it is also an adva n tag e to be famil i ar w i t h w r itin g soft w a re that w o rks w i t h usb hid dev ices. t he source code of the usb2iic.exe progr am is a goo d starting poi nt for such desi gni ng. refer e nces [1]. i2c-usb bridg e guide , in clud ed in the c y 324 0-i2us b kit avail abl e in the c y press o n lin e store. [2]. i2c-usb bridge quick start guide , inclu ded i n the cy32 40-i2us b kit availa ble i n the c y press onlin e store. [3]. an230 4 ? i 2c port e x p and er w i t h f l ash stor age? http:// w w w . c y p r ess.com/desi g n/an23 04 as sociat ed pr oje c t and support material s name descrip tion test2. z i p tachometer e x a m ple project test3. z i p capsense ke yp ad example pr oject test4. z i p three channel a dc exam ple project usb2iic.exe pc soft w a re f o r i 2 c-usb bridge bittiusb2iic.e xe pc soft w a re f o r binar y dat a con v ersion about the author nam e : valeriy k y r y nyuk title : engi neer ba ck ground : eight years e x peri ence w i t h field bus a nd co mmunicati on devic e desi gns . conta c t : lopik @ lviv.farl e p .net cy pres s s e mi co n duc to r 198 c h am pio n c o urt s an j o s e , c a 951 34- 17 09 p h on e: 40 8-9 4 3 - 2 6 00 f a x : 408-9 4 3 - 4 7 3 0 htt p ://w ww .c y p res s .c om ? c y pr ess semi cond u c tor c o r por ati o n , 200 6 . t h e i n f o r m a ti o n cont ai ned h e r e i n i s subj ect to chang e w i thout not i c e. c y pr ess semi co nd u c to r co rp o r atio n a s su m e s n o re sp on sib ilit y f o r th e use o f any ci r c ui try other than ci r c ui tr y embod i ed i n a c y pr e ss pr oduct. n o r does i t conv ey or i m pl y any l i c ense under pat ent o r ot her r i g h ts. c y pr ess pr oducts ar e not w a r r a nted no r i n tende d to be us ed f o r m edi cal , l i f e sup por t, l i f e sav i ng , cr i t i c al contr o l or safe ty appl i c ati ons, u n l e ss pur s ua nt to a n ex pr ess w r i t t en ag r eeme n t w i t h c y pr ess. fur t her mor e , c y pr ess does not a u thor i z e i t s pr oducts for use a s cr i t i c al compo n e n ts i n l i f e- supp or t sy stems w her e a mal f u n cti o n or fai l u r e m a y r eason abl y be ex pected t o r e su lt in sign if ic a n t in jury to th e u s e r . t h e i n clu s io n of c y pr ess pr oducts i n l i f e- supp or t sy stems app l i c ati on i m pl i e s t hat the ma nu factur er assu me s al l r i sk o f suc h us e a n d i n doi ng so i n de m n i f i e s c y pr ess ag ai nst al l char g e s. 9/22/2006 revision ** - 8 -


▲Up To Search▲   

 
Price & Availability of AN2352

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X